package org.opens.javaskill.easypoi.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@Data
@ExcelTarget(value = "department")
public class Department {

    public static final Random random = new Random(System.currentTimeMillis());

    /**
     * 说明:
     * 1. groupName相同的列会被放到一个组中, 即使是跨实例的组;
     */
    @Excel(name = "部门id", width = 20, groupName = "基本信息")
    private Integer id;

    @Excel(name = "部门名称", width = 20)
    private String name;

    public static Department getRandomOne() {
        Department department = new Department();
        department.setId(random.nextInt(1000));
        department.setName("dep " + random.nextInt(1000));
        return department;
    }

    public static List<Department> getRandomList(int number) {
        List<Department> result = new ArrayList<>();
        for (int i = 0; i < number; i++) {
            result.add(getRandomOne());
        }
        return result;
    }

}
